﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ECS_Test
{
    class Sys_Physics : System
    {
        public Sys_Physics(CompTypes[] requiredComponentTypes)
            : base(requiredComponentTypes)
        {

        }
        public override void Update()
        {
            // Just a quick mockup:

            foreach (int _e in entities)
            {
                Comp_Physics phys = (Comp_Physics)GameState.em.allEntities[_e].comps[CompTypes.Physics];
                Comp_Velocity vel = (Comp_Velocity)GameState.em.allEntities[_e].comps[CompTypes.Velocity];

                // Check entities (or entity pairs) for collisions with broad and narrow phases (phys.is):
                // i.e. phys.colliding? phys.collideable?
                // again, for now, though:

                phys.colliding = true; phys.collideable = true;

                if (phys.collideable && phys.colliding)
                {
                    // GetNewVelocityFromCollisionResolution();
                    // Or, for now:
                    vel.x = 0.001f;
                    vel.y = -0.006f; 
                    vel.z = 0f; 
                }

                GameState.em.allEntities[_e].comps[CompTypes.Physics] = phys;
                GameState.em.allEntities[_e].comps[CompTypes.Velocity] = vel;
            }
        }
    }
}
